package mc.contents.etc.init;

import mc.support.task.mgr.TaskLoader;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * Created by Administrator on 14-12-11.
 */
public class InitListener implements ServletContextListener {
    @Override
    public void contextInitialized( ServletContextEvent sce ) {
        ServletContext servletContext = sce.getServletContext();
        WebApplicationContext springContext = WebApplicationContextUtils
                .getWebApplicationContext( servletContext );
        TaskLoader taskLoader = springContext.getBean("taskLoader", TaskLoader.class);
        taskLoader.loadTasks();
    }

    @Override
    public void contextDestroyed( ServletContextEvent sce ) {

    }
}
